package cn.seqdata.jpa.converter;

import javax.persistence.AttributeConverter;

import org.joda.time.LocalTime;

public class LocalTimeConverter implements AttributeConverter<LocalTime, java.sql.Time> {
	public static final LocalTimeConverter instance = new LocalTimeConverter();

	@Override
	public java.sql.Time convertToDatabaseColumn(LocalTime attribute) {
		return null != attribute ? new java.sql.Time(attribute.getMillisOfDay()) : null;
	}

	@Override
	public LocalTime convertToEntityAttribute(java.sql.Time dbData) {
		return null != dbData ? new LocalTime(dbData.getTime()) : null;
	}
}
